<?php

namespace Luka\NavigationBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bridge\Twig\Extension\RoutingExtension;

class NavigationController extends PagenationController {
    //region navigation

    protected function MenuItemAdd($text, $url = "", array $translationParameters = array()){
        $this->NavigationItemAdd(true, $text, $url, $translationParameters);
    }

    protected function MenuItemAddRange($items){
        $navigation = $this->Navigation(true);
        $navigation->addRange($items);
    }

    protected function MenuItemAddWithChildren($text, array $children = array(), $url = "", array $translationParameters = array()){
        $this->NavigationItemAddWithChildren(true, $text, $children, $url, $translationParameters);
    }

    protected function BreadCrumbItemAdd($text, $url = "", array $translationParameters = array()){
        $this->NavigationItemAdd(false, $text, $url, $translationParameters);
    }

    private function NavigationItemAdd($isMenu, $text, $url = "", array $translationParameters = array()){
        $navigation = $this->Navigation($isMenu);
        $navigation->addItem($text, $url, $translationParameters);
    }

    private function NavigationItemAddWithChildren($isMenu, $text, array $children = array(), $url = "", array $translationParameters = array()){
        $navigation = $this->Navigation($isMenu);
        $navigation->addItemWithChildren($text, $children, $url, $translationParameters);
    }

    private function Navigation($isMenu){
        return $this->get("luka_navigation_". ($isMenu ? "menu" : "breadcrumb"));
    }

    //endregion navigation
}